pxSetD6JointTwistLimit(joint%, lowLim#, heighLim#)

Параметры

joint% - соединение
lowLim#
heighLim#

Описание

Устанавливает пределы наклона шарнира.

Смотрите так же

pxSetD6JointAngleMotion, pxSetD6JointLinearLimit, pxSetD6JointPosMotion, pxSetD6JointSwingLimit

Пример

;Пример функции
;pxJCreateD6Joint

Graphics3D 640,480
SetBuffer BackBuffer()
;Global xMot=0, yMot=0, zMot=0, twistMot = 0, swing1Mot = 0, swing2Mot = 0
Global fntArial=LoadFont("Arial",14)

;light
light=CreateLight(1)
PositionEntity light,0,50,20

;cam
cam=CreateCamera()
PositionEntity cam,0,8,-20
;PointEntity cam,campiv
;EntityParent cam,campiv

;plane
plane=CreatePlane()
tile1=LoadTexture("media\cell.bmp")
ScaleTexture tile1,5,5
EntityTexture plane,tile1

;physX
PxCreateWorld(1)
pxSetGravity(0,-30,0)

;create capsule

capsule1 = Create_Px_Capsule(Mesh_Capsule(2, 1), 2, 1)
pxSetPosition(capsule1, 0, 10, 0)
pxSetFrozen(capsule1,1)

capsule2 = Create_Px_Capsule(Mesh_Capsule(2, 1), 2, 1)
pxSetPosition(capsule2, 0, 5, 0)

D6Joint = pxJCreateD6Joint(capsule1, capsule2, 0, 5, 0, 0,-1,0)

pxSetD6JointLinearLimit(D6Joint,5)
pxSetD6JointSwingLimit(D6Joint, 30, 70)
pxSetD6JointTwistLimit(D6Joint, -90, 45)

pxSetD6JointPosMotion(D6Joint , 0, 0, 0)
pxSetD6JointAngleMotion(D6Joint, 0, 0, 0)

Repeat

;cubic control
    If KeyDown(17) pxAddForce(capsule2,0,0,30,0)
    If KeyDown(31) pxAddForce(capsule2,0,0,-30,0)
    If KeyDown(30) pxAddForce(capsule2,-30,0,0,0)
    If KeyDown(32) pxAddForce(capsule2,30,0,0,0)
    If KeyDown(16) pxAddForce(capsule2,0,-30,0,0)
    If KeyDown(18) pxAddForce(capsule2,0,60,0,0)

    If KeyHit(2)
        xMot = xMot+1
        If xMot >2 xMot=0
        pxSetD6JointPosMotion(D6Joint , xMot, yMot, zMot)
    EndIf    
    If KeyHit(3)
         yMot = yMot+1
        If yMot >2 yMot=0
        pxSetD6JointPosMotion(D6Joint , xMot, yMot, zMot)
    EndIf
    If KeyHit(4)
         zMot = zMot+1
        If zMot >2 zMot=0
        pxSetD6JointPosMotion(D6Joint , xMot, yMot, zMot)
    EndIf

    If KeyHit(5)
        twistMot = twistMot+1
        If twistMot >2 twistMot=0
        pxSetD6JointAngleMotion(D6Joint , twistMot, swing1Mot, swing2Mot)
    EndIf    
    If KeyHit(6)
        swing1Mot= swing1Mot+1
        If swing1Mot >2 swing1Mot=0
        pxSetD6JointAngleMotion(D6Joint , twistMot, swing1Mot, swing2Mot)
    EndIf    
    If KeyHit(7)
        swing2Mot= swing2Mot+1
        If swing2Mot >2 swing2Mot=0
        pxSetD6JointAngleMotion(D6Joint , twistMot, swing1Mot, swing2Mot)
    EndIf    


    RenderPhysic(60,0)
    Update_Px_Cube()

    UpdateWorld()
    RenderWorld()
    SetFont fntArial
    Text 5,5,"xMot: "+xMot+" yMot: "+yMot+" zMot: "+zMot
    Text 5,20,"twistMot: "+twistMot+" swing1Mot: "+swing1Mot+" swing2Mot: "+swing2Mot

    Text 5,40,"1 / 2 / 3 / 4 / 5 / 6 - изменение режимов"
    Text 5,55,"w / a / s / d / q / e - добавление сил"
    Flip
Until KeyHit(1)
End

Type Px_Cube
    Field cube_body%
    Field cube_mesh%
End Type

Function Create_Px_Capsule(mesh, height#, radius#)
    ocu.Px_Cube = New Px_Cube

    ocu\cube_mesh = CopyEntity (mesh)
    EntityColor ocu\cube_mesh, Rand(0,255), Rand(0,255), Rand(0,255)

    ocu\cube_body = pxCreateCapsule%(height, radius, 1)
    pxSetPosition(ocu\cube_body, 0, 15, 0)

    Return ocu\cube_body
End Function

;Функция обновляет позиции мешей в соответсвии с позициями физических тел
Function Update_Px_Cube()
    For ocu.Px_Cube = Each Px_Cube
        pxSetEntity(ocu\cube_mesh, ocu\cube_body)
    Next
End Function

;Функция создает меш в форме капсулы
Function Mesh_Capsule(height#, radius#)
    capsule= CreateCylinder()
    ScaleMesh capsule, radius, height/2, radius
    PositionMesh capsule,0,0,0

    sphere1 = CreateSphere()
    ScaleMesh sphere1,radius,radius,radius
    PositionMesh sphere1,0, height/2,0
    AddMesh sphere1,capsule

    sphere2 = CreateSphere()
    ScaleMesh sphere2,radius,radius,radius
    PositionMesh sphere2,0, -height/2,0
    AddMesh sphere2,capsule

    FreeEntity sphere1
    FreeEntity sphere2

    HideEntity capsule
    Return capsule
End Function

К содержанию

Нажмите здесь чтобы увидеть последнюю версию этой странички в режиме online.